﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.Core.Interface;
using System.Collections;

namespace PServiceBus.Core.Runtime.Topics {
    [Serializable]
    public class TopicInfo : ITopic {
        public TopicInfo(ITopic topic) {
            if (topic == null) return;
            Name = topic.Name;
            Contract = topic.Contract;
            ID = topic.ID;
        }
        public TopicInfo() { }
        public static TopicInfo New(string name, TopicContract contract) {
            contract = contract ?? new TopicContract()
            {
                Name = name, Description = name,
                ParameterInfos = new List<TopicParameterInfo>()
            };
            return new TopicInfo() { ID = Guid.NewGuid(), Contract = contract, Name = name };
        }

        public static TopicInfo New(string name) {
            return New(name, null);
        }
        #region ITopic Members

        public string Name { get; set; }

        public TopicContract Contract { get; set; }

        #endregion

        #region IIdentifiable Members

        public Guid ID { get; set; }

        #endregion
    }
}
